(function(){"use strict";BX.namespace("BX.UI");BX.UI.ToolbarManager={toolbars:{},create:function(t){var i=new BX.UI.Toolbar(t);if(this.get(i.getId())){throw new Error("The toolbar instance with the same 'id' already exists.")}this.toolbars[i.getId()]=i;return i},getDefaultToolbar:function(){return this.get("default-toolbar")},get:function(t){return t in this.toolbars?this.toolbars[t]:null}};BX.UI.Toolbar=function(t){t=BX.type.isPlainObject(t)?t:{};this.titleMinWidth=BX.type.isNumber(t.titleMinWidth)?t.titleMinWidth:158;this.titleMaxWidth=BX.type.isNumber(t.titleMaxWidth)?t.titleMaxWidth:"";this.filterMinWidth=BX.type.isNumber(t.filterMinWidth)?t.filterMinWidth:300;this.filterMaxWidth=BX.type.isNumber(t.filterMaxWidth)?t.filterMaxWidth:748;this.currentFavoriteId=BX.type.isNumber(t.currentFavoriteId)?t.currentFavoriteId:0;this.initPagetitleStar();this.id=BX.Type.isStringFilled(t.id)?t.id:BX.Text.getRandom();this.toolbarContainer=t.target;if(!BX.Type.isDomNode(this.toolbarContainer)){throw new Error('BX.UI.Toolbar: "target" parameter is required.')}this.titleContainer=this.toolbarContainer.querySelector(".ui-toolbar-title-box");this.filterContainer=this.toolbarContainer.querySelector(".ui-toolbar-filter-box");this.filterButtons=this.toolbarContainer.querySelector(".ui-toolbar-filter-buttons");this.rightButtons=this.toolbarContainer.querySelector(".ui-toolbar-right-buttons");this.afterTitleButtons=this.toolbarContainer.querySelector(".ui-toolbar-after-title-buttons");if(!this.filterContainer){this.filterMinWidth=0;this.filterMaxWidth=0}this.buttons=Object.create(null);this.buttonIds=BX.Type.isArray(t.buttonIds)?t.buttonIds:[];if(!this.buttonIds.length){return}this.buttonIds.forEach(function(t){var i=BX.UI.ButtonManager.createByUniqId(t);if(i){i.getContainer().originalWidth=i.getContainer().offsetWidth;if(!i.getIcon()&&!BX.Type.isStringFilled(i.getDataSet()["toolbarCollapsedIcon"])){if(i.getColor()===BX.UI.ButtonColor.PRIMARY){i.setDataSet({toolbarCollapsedIcon:BX.UI.ButtonIcon.ADD})}else{console.warn('BX.UI.Toolbar: the button "'+i.getText()+'" '+"doesn't have an icon for collapsed mode. "+'Use the "data-toolbar-collapsed-icon" attribute.')}}this.buttons[t]=i}else{console.warn('BX.UI.Toolbar: the button "'+t+"\" wasn't initialized.")}},this);this.windowWidth=document.body.offsetWidth;this.reduceItemsWidth();window.addEventListener("resize",function(){if(this.isWindowIncreased()){this.increaseItemsWidth()}else{this.reduceItemsWidth()}}.bind(this))};BX.UI.Toolbar.prototype={getButtons:function(){return this.buttons},getButton:function(t){return t in this.buttons?this.buttons[t]:null},getId:function(){return this.id},isWindowIncreased:function(){var t=this.windowWidth;var i=document.body.offsetWidth;this.windowWidth=i;return i>t},getContainerSize:function(){return this.toolbarContainer.offsetWidth},getInnerTotalWidth:function(){return this.toolbarContainer.scrollWidth},reduceItemsWidth:function(){if(this.getInnerTotalWidth()<=this.getContainerSize()){return}var t=Object.values(this.getButtons());for(var i=t.length-1;i>=0;i--){var e=t[i];if(!e.getIcon()&&!BX.Type.isStringFilled(e.getDataSet()["toolbarCollapsedIcon"])){continue}if(e.isCollapsed()){continue}e.setCollapsed(true);if(!e.getIcon()){e.setIcon(e.getDataSet()["toolbarCollapsedIcon"])}if(this.getInnerTotalWidth()<=this.getContainerSize()){return}}},increaseItemsWidth:function(){var t=Object.values(this.getButtons());for(var i=0;i<t.length;i++){var e=t[i];var o=e.getContainer();if(!e.isCollapsed()){continue}var r=this.titleMinWidth+this.filterMinWidth+(this.afterTitleButtons?this.afterTitleButtons.offsetWidth:0)+(this.filterButtons?this.filterButtons.offsetWidth:0)+(this.rightButtons?this.rightButtons.offsetWidth:0)+(o.originalWidth-o.offsetWidth);if(r>this.getContainerSize()){break}e.setCollapsed(false);if(e.getIcon()===e.getDataSet()["toolbarCollapsedIcon"]){e.setIcon(null)}}},initPagetitleStar:function(){var t=BX("uiToolbarStar");if(!t){return false}if(this.currentFavoriteId){BX.addClass(t,"ui-toolbar-star-active")}BX.bind(t,"click",function(){BX.adminFav.titleLinkClick(t,this.currentFavoriteId);if(BX.hasClass(t,"ui-toolbar-star-active")){BX.removeClass(t,"ui-toolbar-star-active")}else{BX.addClass(t,"ui-toolbar-star-active")}setTimeout(function(){BX.removeClass(t,"adm-fav-link-active")},300)}.bind(this));return true}}})();
//# sourceMappingURL=script.map.js